// part1：C12:ex12.6.cpp
// a function to return a vector<int> alocated.
#include <iostream>
#include <vector>
using namespace std;

vector<int> *new_vector(void)
{
  return new (nothrow) vector<int>;
}

void read_ints(vector<int> *pv)
{
  int v;
  while (cin >> v) {
    pv->push_back(v);
  }
}

void print_ints(vector<int> *pv)
{
  for (const auto &v : *pv)
  {
    cout << v << " ";
  }
  cout << endl;
}

int main(int argc, char *argv[])
{
  vector<int> *pv = new_vector();
  if (!pv) {
    cout << "memory not enough!" << endl;
    return -1;
  }

  read_ints(pv);
  print_ints(pv);

  delete pv;
  pv = nullptr;

  return 0;
}
